﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            edit();
        }
        public static int tosql()
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
            conn.Open();
            string sqlstr = "proc_insert";
            SqlCommand cmd = new SqlCommand(sqlstr, conn);
            cmd.Parameters.Add(new SqlParameter("@username", "cv"));
            cmd.Parameters.Add(new SqlParameter("@name", "cv"));
            cmd.Parameters.Add(new SqlParameter("@pwd", "233"));
            cmd.Parameters.Add(new SqlParameter("@type", "2"));
            cmd.CommandType = CommandType.StoredProcedure;
            int r = cmd.ExecuteNonQuery();
            conn.Close();
            return r;
        }
        public static void del()
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
            conn.Open();
            string sqlstr = "proc_del";
            SqlCommand cmd = new SqlCommand(sqlstr, conn);
            cmd.Parameters.Add(new SqlParameter("@id", "3"));
            cmd.CommandType = CommandType.StoredProcedure;
            conn.Close();
        }
        public static void edit()
        {
            SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["constr"].ConnectionString);
            conn.Open();
            string sqlstr = "proc_edit";
            SqlCommand cmd = new SqlCommand(sqlstr, conn);
            cmd.Parameters.Add(new SqlParameter("@id", "1"));
            cmd.Parameters.Add(new SqlParameter("@username", "cv"));
            cmd.Parameters.Add(new SqlParameter("@name", "cv"));
            cmd.Parameters.Add(new SqlParameter("@pwd", "233"));
            cmd.Parameters.Add(new SqlParameter("@type", "2"));
            cmd.CommandType = CommandType.StoredProcedure;
            conn.Close();
        }
    }
}
